//---------------------------------------------------------------------------

//#include <vcl.h>
#pragma hdrstop
#include "stdafx.h"

#include "FPipSelect.h"
#include "CPip.h"
#include "CDShowManager.h"

//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TPipSelect *PipSelect;

extern CPip                       *pPip;


//---------------------------------------------------------------------------
__fastcall TPipSelect::TPipSelect(TComponent* Owner)
   : TForm(Owner)
{
   m_fLB_Pressed=false;
}
//---------------------------------------------------------------------------
void __fastcall TPipSelect::FormMouseDown(TObject *Sender,
      TMouseButton Button, TShiftState Shift, int X, int Y)
{
   if(Button == mbLeft)
   {
      long SC_DRAGMOVE = 0xF012;
      ReleaseCapture();
      SendMessage(Handle, WM_SYSCOMMAND, SC_DRAGMOVE, 0);
     
   }
   if(Button == mbRight)
   {
      pPip->SendSizePos();
      pPip->Hide();
   }

}
//---------------------------------------------------------------------------


void __fastcall TPipSelect::OnMoveFrame(TMessage &Message)
{
   if (pPip == NULL) return;
   TRect r;
   r.Left = (int)(short) LOWORD(Message.LParam);
   r.Top = (int)(short) HIWORD(Message.LParam);
   r.Right = Width;
   r.Bottom = Height;
   pPip->ChangeFramePosition(r);
}

void __fastcall TPipSelect::FormMouseMove(TObject *Sender,
      TShiftState Shift, int X, int Y)
{
   pPip->SetCursorClkFramePos(X, Y);
}
//---------------------------------------------------------------------------


void __fastcall TPipSelect::FormMouseWheel(TObject *Sender,
      TShiftState Shift, int WheelDelta, TPoint &MousePos, bool &Handled)
{
   pPip->ChangeFrameSize(WheelDelta);
   Handled=true;
}
//---------------------------------------------------------------------------

void __fastcall TPipSelect::ApplicationEvents1ShortCut(TWMKey &Msg,
      bool &Handled)
{
   if (Msg.CharCode == VK_ESCAPE)
   {
      pPip->SendSizePos();
      pPip->Hide();
      Handled = true;
   }
}
//---------------------------------------------------------------------------


